<?php

namespace App\Http\Controllers;

use App\Http\Service\UserreportService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
#帖子-用户举报
class UserreportController extends BaseController
{
    private $getRules=[
            'type'=> 'required',
            //'city_code'=>'required',
        ];
    private  $getRulesMessage=[
            'type.required'=> 'type不能为空',
           // 'city_code.required'=> 'city_code不能为空',

        ];
    public $repository;
    public function __construct(UserreportService $repository)
    {
        parent::__construct();
        $this->repository = $repository;
    }

    //我的帖子举报列表
    public function getList(Request $request)
    {
        $data=[
            'user_id'=>$request->json("user_id"),
            'limit'=>$request->json("limit"),
            'page'=>$request->json("page"),
            'type'=>$request->json("type"),

        ];
        $this->success($this->repository->getList($request,$data));
    }

    //举报信息
    public function addData(Request $request)
    {

        $data=[
            'user_id'=>$request->json("people_id"),
            'post_unique_id'=>$request->json("unique_id"),
            'report_reason'=>$request->json("content"),
            'report_evidence'=>$request->json("report_evidence"),
            'report_status'=>1,#默认待处理
            'type'=>$request->json("type"),
        ];
        if($data['report_evidence']=='[]'){
            $data['report_evidence']=[];
        }
        if(empty($data['report_evidence'])){
            $data['report_evidence']=[];
        }
        if(!is_array($data['report_evidence'])){
            $this->error("【report_evidence】 不是数组");
        }
        $data['report_evidence']=json_encode($data['report_evidence'], JSON_UNESCAPED_UNICODE);

        $this->success($this->repository->addData($request,$data));
    }

    # 帖子删除
    public function del(Request $request)
    {
        $ids = $request->json('id');
        if(empty($ids)){
            $this->error('参数错误');
        }
        $data=[
        
        ];
        $this->repository->del($request,$data,$ids);
    }

  

}
